home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: quick decision: is n a power of 2?
- Date: Sun, 21 Jan 96 19:35:22 GMT
- Organization: none
- Message-ID: <822252922snz@genesis.demon.co.uk>
- References: <Pine.OSF.3.91.960119114608.18779E-100000@io.UWinnipeg.ca> <4dpian$gij@oxy.rust.net> <9601201820.AA01752@dxmint.cern.ch>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <9601201820.AA01752@dxmint.cern.ch>
- danpop@mail.cern.ch "Dan Pop" writes:
-
- >I don't think so. ~number & number will _always_ give 0. -number & number
- >will actually work, except for the case when number == 0. That is,
- >assuming a two's complement implementation. On a one's complement or
- >sign-magnitude implementation it won't work at all.
-
- If you go back to the original question number is an unsigned long.
- Therefore sighed integer representations are not really relevant and
- -number & number does what is expected. As I understand it ULONG_MAX is
- guaranteed to be of the form 2^^n - 1.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-